package com.accp.vehiclecare.biz.xzhbiz;

import com.accp.vehiclecare.dao.xzhdao.JurisdictionDao;
import com.accp.vehiclecare.pojo.Jurisdiction;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import  java.util.List;
@Service("JuriBiz")
public class JuriBiz extends ServiceImpl<JurisdictionDao, Jurisdiction> {

    /**
     * 查询角色列表
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public List<Jurisdiction> queryJurisdiction(){
        return super.baseMapper.selectList(null);
    }

    /**
     * 新增角色
     * @param jurisdiction
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean addJurisdiction(Jurisdiction jurisdiction){
        jurisdiction.setCreatedate(new Date());
        jurisdiction.setJurstatus(0);
        int count = super.baseMapper.insert(jurisdiction);
        return count !=0;
    }

    /**
     * 修改角色
     * @param jurisdiction
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean amendJurisdiction(Jurisdiction jurisdiction){
        int count = super.baseMapper.updateById(jurisdiction);
        return count !=0;
    }
}
